package com.gopay.bis.tbank.mtpay.operation;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.gopay.common.domain.bank.MtPayBaseMessage;

/**
 * 
 * @MtPayBuildMessage.java
 * @author WangHongFei
 */
public class MtPayBuildMessage {
    /**
     * 无卡支付
     * 
     * @param MtPayBaseMessage
     * @return Map
     */
    public Map buildMtPay(MtPayBaseMessage mtPayBaseMessage) throws Exception{
        String orderDate14 = mtPayBaseMessage.getOrderDate();
        Map<String, Comparable> tempMap = new ConcurrentHashMap<String, Comparable>();
        Map<String, Comparable> mtempMap = (Map<String, Comparable>) mtPayBaseMessage.getMtbPayHashMap();
        tempMap.put("mercNo", mtempMap.get("mercNo"));
        tempMap.put("orderNo", mtPayBaseMessage.getOrderId());
        tempMap.put("msgType", mtempMap.get("msgType"));
        tempMap.put("txnType", mtempMap.get("txnType"));
        tempMap.put("orderAmount", mtPayBaseMessage.getAmount().toString());
        tempMap.put("curCode", mtPayBaseMessage.getCurCode());
        tempMap.put("mainAccount", mtPayBaseMessage.getCardNo());
        tempMap.put("validDate", mtPayBaseMessage.getAvailableDate());
        tempMap.put("CVV2", mtPayBaseMessage.getSecrityCode());
        tempMap.put("orderDate", orderDate14.substring(0, 8));
        tempMap.put("orderTime", orderDate14.substring(8, orderDate14.length()));
        return tempMap;
    }

    /**
     * 无卡冲正
     * 
     * @param MtPayBaseMessage
     * @return Map
     */
    public Map buildMtPayFlush(MtPayBaseMessage mtPayBaseMessage) throws Exception{
        String orderDate14 = mtPayBaseMessage.getOrderDate();
        Map<String, Comparable> tempMap = new ConcurrentHashMap<String, Comparable>();
        Map<String, Comparable> mtempMap = (Map<String, Comparable>) mtPayBaseMessage.getMtbPayHashMap();
        tempMap.put("mercNo", mtempMap.get("mercNo"));
        tempMap.put("orderNo", mtPayBaseMessage.getOrderId());
        tempMap.put("msgType", mtempMap.get("msgType"));
        tempMap.put("txnType", mtempMap.get("txnType"));
        tempMap.put("orderAmount", mtPayBaseMessage.getAmount().toString());
        tempMap.put("curCode", mtPayBaseMessage.getCurCode());
        tempMap.put("orderDate", orderDate14.substring(0, 8));
        tempMap.put("orderTime", orderDate14.substring(8, orderDate14.length()));
        tempMap.put("orgOrderNo", mtempMap.get("orgOrderNo"));
        return tempMap;
    }

}
